package com.eportal.api;

import net.sf.json.JSONObject;

public class MdOpenBaseJson {

	
	
	
	public static MdOpenBaseJson parse(String json){
		JSONObject obj =  JSONObject.fromObject(json);
		MdOpenBaseJson bean = new MdOpenBaseJson();
		if(obj.has("code")){
			bean.setCode(obj.getString("code"));
		}
		if(obj.has("msg")){
			bean.setMsg(obj.get("msg"));
		}
		if(obj.has("status")){
			bean.setStatus(obj.getString("status"));
		}
		//MdOpenBaseJson bean = (MdOpenBaseJson)JSONObject.toBean(JSONObject.fromObject(json), MdOpenBaseJson.class);
		bean.setJsonContent(json);
		return bean;
	}
	
	public static void parse(String json, MdOpenBaseJson bean) {
		MdOpenBaseJson bean_ = parse(json) ;
		bean.setCode(bean_.getCode());
		bean.setMsg(bean_.getMsg());
		bean.setMsg_(bean_.getMsg_());
		bean.setStatus(bean_.getStatus());
		bean.setJsonContent(bean_.getJsonContent());
	}
	
	/**
	 * 请求是否成功,成功返回true
	 */
	public boolean isSuccess(){
		if("0".equals(code)){
			return true;	
		}
		return false;
	}
	
	private String jsonContent;
	
	private String code;
	
	private String msg_;
	
	private String status;
	
	/**
	 * 开放平台返回的msg有时是String,有时是JsonObject,所以用Object
	 */
	private Object msg;

	public String getJsonContent() {
		return jsonContent;
	}

	public void setJsonContent(String jsonContent) {
		this.jsonContent = jsonContent;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMsg_() {
		return msg_;
	}

	public void setMsg_(String msg_) {
		this.msg_ = msg_;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Object getMsg() {
		return msg;
	}

	public void setMsg(Object msg) {
		this.msg = msg;
	}



	
}
